package com.huangliusong.desigin.pattern.creational.simplefactory;

/**
 * @author huangliusong
 * @since 2018/10/9
 * {@link }
 */
public class VideoFactory {
    //    public Video getVideo(String type){
//        if ("java".equalsIgnoreCase(type)){
//            return new JavaVideo();
//        }else if ("python".equalsIgnoreCase(type)){
//            return new PythonVideo();
//        }else {
//            return null;
//        }
//    }
    public Video getVideo(Class c) throws ClassNotFoundException, IllegalAccessException, InstantiationException {
        //使用反射建造简单工厂
        Video video=null;
        video= (Video) Class.forName(c.getName()).newInstance();
        return video;
    }
}
